${page.setTitle("push-center| GOPS")}
<div class="body-pla-content">
	<div class="s-table-wapper">
	<form action="">
		<table class="s-table">
			<tr>
				<td>
					域：
				</td>
				<td>
					<input type="text" id="domainName" />
					<input type="hidden" name="domainId"  id="domainId" value="${domainId!}"/>
				</td>
				<td>
					渠道ID：
				</td>
				<td>
					<input type="text" name="appId"  id="appId" value="${appId!}"/>
				</td>
				<td><input id="btnSearch"  type="button" value="查询"  class="l-button"/>
				<input type="reset" value="清空" class="l-button l-button-reset"/> 
				</td>	
			</tr>
			
		</table>
		</form>
	</div>
	<div id="maingrid" style="margin:0; padding:0"></div>
	<div style="display:none;">
</div>



<script type="text/javascript">


var grid;
$(function () {
     var columns= [
       				{ display: 'ID', name: 'id', width: 30},
       			
       				{ display: '域id', name: 'domainId', width: 100},
       				{ display: '域名称', name: 'domainName', width: 100},
       				{ display: 'app_id', name: 'appId', width: 100},
       				{ display: 'app_channel_id', name: 'appChannelId', width: 100},
       				{ display: '备注', name: 'memo'},
       				{ display: '生成时间', name: 'gmtCreated', width: 150,type:"datetime2"},
       				{ display: '修改时间', name: 'gmtModified', width: 150,type:"datetime2"}
                   ];
     var toolbar={
		 items: [
		 	 {text: '增加', click: toolbarBtnItemClick, icon:'add'},
			 { line:true },
			  { text: '修改', click: toolbarBtnItemClick,icon:'modify'},
			 { line:true },
			 { text: '删除', click: toolbarBtnItemClick,icon:'delete'}
		]
     };
    	
	grid = $("#maingrid").ligerGrid({
						columns:columns,
						toolbar:toolbar,
						checkbox:true,
						enabledSort:false,
						pageSize:10,
						dataAction:'server',
						root:'rows',
						record :'total',
						pageParmName :'page',
						pagesizeParmName :'pageSize',
						width: '100%',
						height:'90%',
						url:'${appServer}/domainappchannel/query.json',
						parms : $("form").serializeArray(),
						method:'get',
						onSuccess:function(data, grid){
							if(data.hasError){
								$.ligerDialog.error(data.message);
							}
						}
					});
     	
     $("#pageloading").hide();
     
      $("#btnSearch").click(function(){
		 search();
	 });
});

function search(){
	 var appKey=$("#appKey");
 	 grid.setOptions( {
 		  		url: '${appServer}/domainappchannel/query.json',
 		  		pageSize:15,
 		  		page:1,
 		  		dataAction:'server',
                parms : $("form").serializeArray()
         });
}

//工具条事件
function toolbarBtnItemClick(item) {
	var url= null;
    switch (item.icon) {
       	 case "add":
        	url= "${appServer}/domainappchannel/add";
        	openWindow(url, '添加', 700, 500);  
            break;
         case "modify":
        	var data = grid.getCheckedRows();
            if (data.length != 1){
                $.ligerDialog.error('请选择一条需要修改的记录!');
                return;
            }
            url = "${appServer}/domainappchannel/update/"+data[0].id;
        	openWindow(url, '修改', 700, 500);  
            break;
         case "delete":
        	var data = grid.getCheckedRows();
            if (data.length != 1){
                $.ligerDialog.error('请选择一条需要删除的记录!');
                return;
            }
            jQuery.ligerDialog.confirm('确定删除吗?', function (confirm) {
                if (confirm){
                	  $.ajax({
              	        url: "${appServer}/domainappchannel/delete.json",   
              	        data: {id:data[0].id}, 
              	        type: "POST",
              	        success: function(result) {
              	        	if(result.hasError) {
              					$.ligerDialog.error(result.message);
              	        	}else{
              	        		$.ligerDialog.success(result.message);
              	        		window.search();
              	        	}
              	        }
              	    });
                 }
            });
            break;
    }
}


//-----------------domain_start -----------
 $(function ()
        { 
            $("#domainName").ligerComboBox({
                onBeforeOpen: f_selectContact3, width:150
            });
        });
        function f_selectContact3()
        {
            $.ligerDialog.open({ title: ' ++选择域', name:'winselector',width: 550, height: 400,  url: '${appServer}/domain/listall-domain', buttons: [
                { text: '确定', onclick: f_selectContactOK3 },
                { text: '取消', onclick: f_selectContactCancel3 }
            ]
            });
            return false;
        }
        function f_selectContactOK3(item, dialog)
        {
			var fn = dialog.frame.f_select || dialog.frame.window.f_select; 
            var data = fn(); 
            if (!data)
            {
                alert('请选择行!');
                return;
            }
            $("#domainId").val(data.id);
            $("#domainName").val(data.name);
            dialog.close();
        }
        function f_selectContactCancel3(item, dialog)
        {
            dialog.close();
        }
	
	
	//------------------------domain---------end

</script>
